翻訳と辞書
Words near each other
・ Longest bar in Australia
・ Longest bridge
・ Longest climbing salamander
・ Longest common subsequence problem
・ Longest common substring problem
・ Longest Day
・ Longest Day of Nelson
・ Longest element of a Coxeter group
・ Longest English sentence
・ Longest fence in the world
・ Longest increasing subsequence
・ Longest linear sequence
・ Longest NCAA Division I football winning streaks
・ Longest Night
・ Longest Night Service
Longest palindromic substring
・ Longest path problem
・ Longest prefix match
・ Longest professional baseball game
・ Longest recorded sniper kills
・ Longest reigning heavyweight champions
・ Longest repeated substring problem
・ Longest rivers of the United Kingdom
・ Longest squash match records
・ Longest tennis match records
・ Longest tiebreaker in tennis
・ Longest train services
・ Longest trains
・ Longest uncrossed knight's path
・ Longest word in English


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Longest palindromic substring : ウィキペディア英語版
Longest palindromic substring
In computer science, the longest palindromic substring or longest symmetric factor problem is the problem of finding a maximum-length contiguous substring of a given string that is also a palindrome. For example, the longest palindromic substring of "bananas" is "anana". The longest palindromic substring is not guaranteed to be unique; for example, in the string "abracadabra", there is no palindromic substring with length greater than three, but there are two palindromic substrings with length three, namely, "aca" and "ada". In some applications it may be necessary to return all maximal palindromic substrings (that is, all substrings that are themselves palindromes and cannot be extended to larger palindromic substrings) rather than returning only one substring or returning the maximum length of a palindromic substring.
found a linear time algorithm for listing all the palindromes that appear at the start of a given string. However, as observed e.g., by , the same algorithm can also be used to find all maximal palindromic substrings anywhere within the input string, again in linear time. Therefore, it provides a linear time solution to the longest palindromic substring problem. Alternative linear time solutions were provided by , and by , who described a solution based on suffix trees. Efficient parallel algorithms are also known for the problem.〔, .〕
The longest palindromic substring problem should not be confused with the different problem of finding the longest palindromic subsequence.
==Manacher's algorithm==
To find in linear time a longest palindrome in a string, an algorithm may take advantage of the following characteristics or observations about a palindrome and a sub-palindrome:
# The left side of a palindrome is a mirror image of its right side.
# (Case 1) A third palindrome whose center is within the right side of a first palindrome will have exactly the same length as that of a second palindrome anchored at the mirror center on the left side, if the second palindrome is within the bounds of the first palindrome by at least one character.
# (Case 2) If the second palindrome meets or extends beyond the left bound of the first palindrome, then the third palindrome is guaranteed to have at least the length from its own center to the right outermost character of the first palindrome. This length is the same from the center of the second palindrome to the left outermost character of the first palindrome.
# To find the length of the third palindrome under Case 2, the next character after the right outermost character of the first palindrome would then be compared with its mirror character about the center of the third palindrome, until there is no match or no more characters to compare.
# (Case 3) Neither the first nor second palindrome provides information to help determine the palindromic length of a fourth palindrome whose center is outside the right side of the first palindrome.
# It is therefore desirable to have a palindrome as a reference (i.e., the role of the first palindrome) that possesses characters furtherest to the right in a string when determining from left to right the palindromic length of a substring in the string (and consequently, the third palindrome in Case 2 and the fourth palindrome in Case 3 could replace the first palindrome to become the new reference).
# Regarding the time complexity of palindromic length determination for each character in a string: there is no character comparison for Case 1, while for Cases 2 and 3 only the characters in the string beyond the right outermost character of the reference palindrome are candidates for comparison (and consequently Case 3 always results in a new reference palindrome while Case 2 does so only if the third palindrome is actually longer than its guaranteed minimum length).
# For even-length palindromes, the center is at the boundary of the two characters in the middle.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Longest palindromic substring」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.